//
//  CC_AnchorSinger_CollectionViewCell.m
//  HimalayaMountain
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CC_AnchorSinger_CollectionViewCell.h"
#import "CCBaceHeaderImageView.h"
#import "CCBaseMainTitleLabel.h"
#import "CCBaseSubHeadLabel.h"
#import "CCBaseImageView.h"
#import "CC_AnchorDetailed_Model.h"

@interface CC_AnchorSinger_CollectionViewCell ()

@property(nonatomic, retain) CCBaceHeaderImageView *headerImageView;
@property(nonatomic, retain) CCBaseMainTitleLabel *nameLabel;
@property(nonatomic, retain) CCBaseImageView *vImage;// V字图片
@property(nonatomic, retain) CCBaseSubHeadLabel *infoLabel;
@property(nonatomic, retain) CCBaseImageView *tranksCounts;  // 关注图片
@property(nonatomic, retain) CCBaseSubHeadLabel *tranksCountsLabel;
@property(nonatomic, retain) CCBaseImageView *follower;   // 被关注图片
@property(nonatomic, retain) CCBaseSubHeadLabel *followersCountsLabel;
@property(nonatomic, retain) CCBaseImageView *attention; // 加关注图片

@end



@implementation CC_AnchorSinger_CollectionViewCell

- (void)dealloc
{
    [_headerImageView release];
    [_nameLabel release];
    [_vImage release];
    [_infoLabel release];
    [_tranksCounts release];
    [_tranksCountsLabel release];
    [_follower release];
    [_followersCountsLabel release];
    [_attention release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        self.headerImageView = [[CCBaceHeaderImageView alloc]init];
        [self.contentView addSubview:_headerImageView];
        [_headerImageView release];
        
        self.nameLabel = [[CCBaseMainTitleLabel alloc]init];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];
        
        self.vImage = [[CCBaseImageView alloc]init];
        self.vImage.image = [UIImage imageNamed:@"sr_vicon@2x.png"];
        [self.contentView addSubview:_vImage];
        [_vImage release];
        
        self.infoLabel = [[CCBaseSubHeadLabel alloc]init];
        [self.contentView addSubview:_infoLabel];
        [_infoLabel release];
        
        self.tranksCounts = [[CCBaseImageView alloc]init];
        self.tranksCounts.image = [UIImage imageNamed:@"album_tracks@2x.png"];
        [self.contentView addSubview:_tranksCounts];
        [_tranksCounts release];
        
        self.tranksCountsLabel = [[CCBaseSubHeadLabel alloc]init];
        [self.contentView addSubview:_tranksCountsLabel];
        [_tranksCountsLabel release];
        
        self.follower = [[CCBaseImageView alloc]init];
        self.follower.image = [UIImage imageNamed:@"user_fans@2x.png"];
        [self.contentView addSubview:_follower];
        [_follower release];
        
        self.followersCountsLabel = [[CCBaseSubHeadLabel alloc]init];
        [self.contentView addSubview:_followersCountsLabel];
        [_followersCountsLabel release];
        
        self.attention = [[CCBaseImageView alloc]init];
        self.attention.image = [UIImage imageNamed:@"np_headview_nofollow_n@2x.png"];
        [self.contentView addSubview:_attention];
        [_attention release];
        
        
    }
    return self;
}

-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    // return CGSizeMake(SCREENWIDTH - SPACED * 2, SCREENHEIGHT / 7);

    
    // 头像大小
    [self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SCREENHEIGHT / 7 - 3 * SPACED, SCREENHEIGHT / 7 - 3 * SPACED));
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-1.5 * SPACED);
        
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SPACED * 8, SPACED * 1.8));
        make.top.equalTo(self.contentView.mas_top).offset(SPACED);
        make.left.equalTo(self.headerImageView.mas_right).offset(SPACED);
        
    }];
    
    [self.vImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SPACED, SPACED));
        make.top.equalTo(self.contentView.mas_top).offset(SPACED);
        make.left.equalTo(self.nameLabel.mas_right).offset(5);
        
    }];
    
    [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(200, SPACED * 1.5));
        make.top.equalTo(self.nameLabel.mas_bottom).offset(SPACED * 0.8);
        make.left.equalTo(self.headerImageView.mas_right).offset(SPACED);
        
    }];
    
    // 关注图片大小设置
    [self.tranksCounts mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SPACED, SPACED));
        make.top.equalTo(self.infoLabel.mas_bottom).offset(SPACED * 0.5);
        make.left.equalTo(self.headerImageView.mas_right).offset(SPACED);
    }];
    

    [self.tranksCountsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SPACED, SPACED * 2));  // 需要自适应
        make.top.equalTo(self.infoLabel.mas_bottom).offset(SPACED * 0.5);
        make.left.equalTo(self.tranksCounts.mas_right).offset(3);
        
    }];
    
    //  本关注人图片大小设置
    [self.follower mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(SPACED, SPACED));
        make.top.equalTo(self.infoLabel.mas_bottom).offset(SPACED * 0.5);
        make.left.equalTo(self.tranksCountsLabel.mas_right).offset(SPACED * 0.5);

    }];
    
    [self.followersCountsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SPACED, SPACED));
        make.top.equalTo(self.infoLabel.mas_bottom).offset(SPACED * 0.5);
        make.left.equalTo(self.follower.mas_right).offset(SPACED * 0.5);

    }];
    
    
    // 加关注图片大小
    [self.attention mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake((SCREENHEIGHT / 7 - 6 * SPACED) * 0.7, SCREENHEIGHT / 7 - 6 * SPACED));
        make.right.equalTo(self.contentView.mas_right).offset(-5);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-2 * SPACED);
        
    }];
    

}


-(void)setAnchorDetailedModel:(CC_AnchorDetailed_Model *)anchorDetailedModel{
    if (_anchorDetailedModel != anchorDetailedModel) {
        [_anchorDetailedModel release];
        _anchorDetailedModel = [anchorDetailedModel retain];
    }
    
    [self.headerImageView setImageWithURL:[NSURL URLWithString:anchorDetailedModel.middleLogo]];
    
    self.nameLabel.text = anchorDetailedModel.nickname;
    self.infoLabel.text = anchorDetailedModel.verifyTitle;
    self.tranksCountsLabel.text = [NSString stringWithFormat:@"%@", anchorDetailedModel.tranksCounts];
    self.followersCountsLabel.text =[NSString stringWithFormat:@"%@", anchorDetailedModel.followersCounts];

    
}




@end
